cpprb v10.1.0 can save & load transitions

From cpprb version 10.1.0, ReplayBuffer and its sub-classes can save and load transitions.

from cpprb import ReplayBuffer

rb1 = ReplayBuffer(256,
                   {"obs": {"shape": 3}, "act": {},
                    "rew": {}, "done": {}},
                   next_of="obs")

rb2 = ReplayBuffer(256,
                   {"obs": {"shape": 3}, "act": {},
                    "rew": {}, "done": {}},
                   next_of="obs")

rb1.add(obs=[1, 2, 3], act=1, rew=1, next_obs=[2, 3, 4], done=0)

# File extension must be ".npz"
rb1.save_transitions("transitions.npz")
rb2.load_transitions("transitions.npz")

If you need to compress file size aggressively, you can use safe=False option at save_transitions. When the option is enabled, the buffer dumps internal data structure directly without reconstruct of well-organized set of transitions. For example, if your environment is large dimensional state and next_of is enabled, the safe=False option reduces duplicated “next state”, resulting smaller file size.

References

Avatar
Hiroyuki Yamada

My research interests include machine learning, cloud native conputing.

Related